<?php

defined( 'PDNS_AUTH' ) or die( "Unauthorized" );

class Router{
	private static $section;

	public static function getSection(){
		if( ! isset( self::$section ))
			self::$section = Request::getWord( 'section' );

		return self::$section;
	}

	public static function route(){
		ob_start();

		$section = self::getSection(); 
		if( $section ){
			require_once( "controllers/$section.php" );
			$class = $section."Controller";
			$controller = new $class();
			$controller->action( Request::getWord( 'action' ));
		}

		$output = ob_get_contents();
		ob_end_clean();

		Output::setOutput( 'option', $output );
	}
}
